package com.vans.practice.alghr;

import java.util.Arrays;

/**
 * @Description:
 * @Note:
 * @Author elle
 * @Date 2020/10/11 17:00
 */
public class Shell {

    public static void main(String[] args) {
        int[] a = {9,6,19,11,1,5,10,18};
        sort(a);
        System.out.println(Arrays.toString(a));
    }

    /**
     * 希尔排序
     *
     * @param arr
     */
    private static void sort(int[] arr) {
        int len = arr.length;
        for (int gap = (int) Math.floor(len/2); gap > 0 ; gap =(int) Math.floor(gap/2)) {
            for (int i = gap; i < len; i++) {
                int j = i;
                if (arr[j-gap] > arr[j]) {
                    int temp = arr[j];
                    arr[j] = arr[j-gap];
                    arr[j-gap] = temp;
                }
            }
        }
    }
}
